home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / agg / Association.c < prev    next >
C/C++ Source or Header  |  1992-01-23  |  3KB  |  78 lines

  1. /* --------------------------------------------------------------------------
  2.  * Copyright 1992 by Forschungszentrum Informatik (FZI)
  3.  *
  4.  * You can use and distribute this software under the terms of the licence
  5.  * you should have received along with this program.
  6.  * If not or if you want additional information, write to
  7.  * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  8.  * D-7500 Karlsruhe 1, Germany.
  9.  * --------------------------------------------------------------------------
  10.  */
  11. // **************************************************************************
  12. // Module Association                06/09/90                Juergen Uhl (ju)
  13. //
  14. // **************************************************************************
  15. // implements methods of classes: Association
  16. // **************************************************************************
  17.  
  18. #include "sys.h"
  19. #include "agg_err.h"
  20. #include "trc_agg.h"
  21.  
  22. #include "agg_sos.h"
  23.  
  24. // **************************************************************************
  25. sos_Bool sos_Object_sos_Object_Association::is_role1 (sos_Object o)
  26. // **************************************************************************
  27. {
  28.    // The function tests if an object is an element of the aggregate.
  29.    // The test may be based on equality or identity, depending on
  30.    // the value of the "role1_based_on_equal" attribute.
  31.  
  32.    T_PROC ("sos_Object_sos_Object_Association::is_role1");
  33.    TT (agg_H, T_ENTER);
  34.  
  35.    sos_Bool result = FALSE;
  36.    sos_Object_sos_Object_Association a = self;
  37.    sos_Bool based_on_equal = self.get_role1_based_on_equal();
  38.  
  39.    agg_iterate_association (a, sos_Object role1, sos_Object role2)
  40.    {  if (agg_same_entity (o, role1, based_on_equal, EQ_STRONG))
  41.       {  result = TRUE;
  42.      break;
  43.       }
  44.    }
  45.    agg_iterate_association_end (a, role1, role2);
  46.  
  47.    TT (agg_H, T_LEAVE);
  48.    return result;
  49. } // ** is_role1 **
  50.  
  51. // **************************************************************************
  52. sos_Bool sos_Object_sos_Object_Association::is_role2 (sos_Object o)
  53. // **************************************************************************
  54. {
  55.    // The function tests if an object is an element of the aggregate.
  56.    // The test may be based on equality or identity, depending on
  57.    // the value of the "role2_based_on_equal" attribute.
  58.  
  59.    T_PROC ("sos_Object_sos_Object_Association::is_role2");
  60.    TT (agg_H, T_ENTER);
  61.  
  62.    sos_Bool result = FALSE;
  63.    sos_Object_sos_Object_Association a = self;
  64.    sos_Bool based_on_equal = self.get_role2_based_on_equal();
  65.  
  66.    agg_iterate_association (a, sos_Object role1, sos_Object role2)
  67.    {  if (agg_same_entity (o, role2, based_on_equal, EQ_STRONG))
  68.       {  result = TRUE;
  69.      break;
  70.       }
  71.    }
  72.    agg_iterate_association_end (a, role1, role2);
  73.  
  74.    TT (agg_H, T_LEAVE);
  75.  
  76.    return result;
  77. } // ** is_role2 **
  78.